﻿using System;
using System.Linq;
using BizControl.Dal.Interfaces;
using System.Collections.Generic;
using BizControl.Dal.DTOs;
using Csla.Data;

namespace BizControl.DalLinq.DALObjects
{
  public class PersonDal : IPersonDal
  {
    #region IPersonDal Members

    public List<PersonDTO> Fetch()
    {
      using (var ctx = ContextManager<BusinessControl2DataContext>.GetManager(Database.BizControlDB))
      {
        var result = from r in ctx.DataContext.People
                     where !r.IsDeleted
                     select new PersonDTO
                     {
                       PersonId = r.PersonId,
                       FirstName = r.FirstName,
                       LastName = r.LastName,
                       MiddleName = r.MiddleName,
                       Photo = r.Photo,
                       Email = r.Email,
                       UserType = r.UserType,
                       PasswordHash = r.PasswordHash,
                       PasswordSalt = r.PasswordSalt,
                       Login = r.Login,
                       Comment = r.Comment,
                       CreatedBy = r.CreatedBy,
                       CreatedOn = r.CreatedOn,
                       LastChanged = r.LastChanged,
                       LastChangedBy = r.LastChangedBy,
                       TimeStamp = r.TimeStamp.ToArray()
                     };
        return result.ToList();
      }
    }

    public List<PersonDTO> Fetch(string nameFilter)
    {
      throw new NotImplementedException();
    }

    public PersonDTO Fetch(Guid id)
    {
      throw new NotImplementedException();
    }

    public bool Exists(Guid id)
    {
      throw new NotImplementedException();
    }

    public void Insert(PersonDTO item)
    {
      throw new NotImplementedException();
    }

    public void Update(PersonDTO item)
    {
      throw new NotImplementedException();
    }

    public void Delete(Guid id)
    {
      throw new NotImplementedException();
    }

    #endregion
  }
}
